package org.simple.framework.service.flow.choreographer;

import org.simple.framework.service.step.FlowStepService;
import org.simple.framework.service.step.StepService;
import org.springframework.beans.factory.annotation.Autowired;

import com.simple.framework.infrastructure.pojo.Flow;
import com.simple.framework.infrastructure.pojo.FlowStep;
import com.simple.framework.infrastructure.pojo.Step;

public abstract class AbstractFlowChoreographer implements FlowChoreographer {

	@Autowired
	protected FlowStepService flowStepService;

	@Autowired
	protected StepService StepService;

	public void addStep(Flow flow, Step step) {
		addStep(flow, step, null);
	}

	public void addStep(Flow flow, Step step, String stepPrefixName) {
		if (stepPrefixName != null)
			step.setStepName(stepPrefixName + step.getStepName());
		flow.getSteps().add(step);
	}

	public void addFlowStep(Flow flow, FlowStep flowStep) {
		addFlowStep(flow, flowStep, null);
	}

	public void addFlowStep(Flow flow, FlowStep flowStep, String flowStepPrefixName) {
		flowStep.setPrefixFlowStepName(flowStepPrefixName);
		flow.getSteps().add(flowStep);
	}
}
